import datetime

from flask import Flask
from flask_login import LoginManager
from flask_sqlalchemy import SQLAlchemy
from flask_cors import CORS
from .config import *


app = Flask(__name__,
            template_folder='../templates',
            static_folder='../assets',
            static_url_path='/assets'
            )

# app.config['SQLALCHEMY_DATABASE_URI'] = f'mysql+pymysql://root:root@localhost:8306/myblog_db'
app.config['SQLALCHEMY_DATABASE_URI'] = f'{DB_TYPE}+{ENGINE}://{MYSQL_USER}:{MYSQL_PASSWORD}@{MYSQL_HOST}:{MYSQL_PORT}/{MYSQL_DB}'

app.config['SECRET_KEY'] = 'abcdefg'
app.config['PERMANENT_SESSION_LIFETIME'] = datetime.timedelta(days=7)
CORS(app=app)
login_manager = LoginManager(app)

db = SQLAlchemy(app)